package com.keepsport.keepsportapi.controller;


import com.keepsport.keepsportapi.config.SystemConfig;
import com.keepsport.keepsportapi.entity.User;
import com.keepsport.keepsportapi.entity.UserDetail;
import com.keepsport.keepsportapi.service.intf.UserDetailService;
import com.keepsport.keepsportapi.vo.R;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@Api(tags = "修改个人资料")
@RequestMapping("/api/userDetail/")
@CrossOrigin
public class UserDetailController {
    @Resource
    private UserDetailService service;

    @PostMapping("update.do")
    public R update(@RequestBody UserDetail userDetail, HttpServletRequest request) {
        //System.out.println(request.getIntHeader(SystemConfig.TOKEN_HEADER));
        return service.update(userDetail,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }

    @PostMapping("updateUserName.do")
    public R updateName(@RequestBody User user) {
        return service.updateName(user);
    }

//    @PostMapping("updateUser.do")
//    public R updateUserName(@RequestBody User user) {
//        return service.updateUserName(user);
//    }
//
//    @GetMapping("all.do")
//    public R selectAll(int token) {
//        return service.selectAll(token);
//    }

//    @GetMapping("name.do")
//    public R updateName(UserDetailDto dto) {
//        return service.updateName(dto);
//    }
//    @PostMapping("city.do")
//    public R updateCity(UserDetailDto dto) {
//        return service.updateCity(dto);
//    }
//    @PostMapping("sex.do")
//    public R updateSex(UserDetailDto dto) {
//        return service.updateCity(dto);
//    }
}
